<?php
require_once('Zend/Loader.php');
class Blogger {

    public function post($param) {

        $asin = $xml->Items->Item->ASIN;

        $title = $param['title'];
        $content = $param['content'];
        $keyword = $param['keyword'];


        /* Post to Blogger */
        $client = Zend_Gdata_ClientLogin::getHttpClient($param['email'], $param['password'], 'blogger', null,
                Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null,
                Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
        $gdClient = new Zend_Gdata($client);

        $query = new Zend_Gdata_Query('http://www.blogger.com/feeds/default/blogs');
        $feed = $gdClient->getFeed($query);

        $uri = 'http://www.blogger.com/feeds/' . $param['blog_id'] . '/posts/default';
        $entry = $gdClient->newEntry();
        $entry->title = $gdClient->newTitle($title);
        $entry->content = $gdClient->newContent($content);
        $entry->content->setType('text');

        $createdPost = $gdClient->insertEntry($entry, $uri);
        $idText = split('-', $createdPost->id->text);
        $url = $createdPost->link[4]->href;
        $newPostID = $idText[2];

        return $newPostID;
    }
}
?>
